/*
    $Header: /Windows/Shell/ShellExt.root/ShellExt/src/CJunction.h 1     08-01-05 0:08 Ken $
    $Log: /Windows/Shell/ShellExt.root/ShellExt/src/CJunction.h $
 * 
 * 1     08-01-05 0:08 Ken
*/

#pragma once

#ifndef _CJUNCTION_H_
#define _CJUNCTION_H_

class CJunction
{
public:
typedef enum _JUNCTION_TYPE{NOT_JUNCTION=0, SYMBOLIC_LINK, JUNCTION, MOUNT_POINT} JUNCTION_TYPE;

//static functions
public:
    static BOOL CanCreateJunction(const TCHAR* pszJunctPath);
    static BOOL IsJunction(const TCHAR* pszJunctPath, TCHAR* pszTgtPath=NULL, DWORD dwBufLen=0)
    { return (NOT_JUNCTION==JunctionType(pszJunctPath, pszTgtPath, dwBufLen)) ? FALSE: TRUE;};
    static JUNCTION_TYPE JunctionType(const TCHAR* pszJunctPath, TCHAR* pszTgtPath=NULL, DWORD dwBufLen=0);
    static BOOL CreateJunction(const TCHAR* pszJunctPath, const TCHAR* pszTgtPath, BOOL fForce=FALSE);
    static BOOL DelJunction(const TCHAR* pszJunctPath){return RemoveDirectory( pszJunctPath );};


public:
    CJunction(void):m_JunctionType(CJunction::NOT_JUNCTION) {m_szJunctPath[0]=0;m_szTgtPath[0]=0;};
    CJunction(const TCHAR* pszJunctPath);
    CJunction(const CJunction &cjunct);
    CJunction& operator =(const CJunction& cjunct);
    ~CJunction(void){};
    BOOL Initialize(const TCHAR* pszJunctPath=NULL);

public:
    BOOL CreateJunction(const TCHAR* pszTgtPath);
    BOOL DelJunction(){return (NOT_JUNCTION==m_JunctionType) ? FALSE: RemoveDirectory(m_szJunctPath);};
    BOOL IsJunction(){return (NOT_JUNCTION==m_JunctionType) ? FALSE:TRUE;};

    TCHAR* GetJunctionTgt(){return (NOT_JUNCTION==m_JunctionType) ? NULL:m_szTgtPath;};
    TCHAR* GetJunctionName(){return m_szJunctPath;};
    JUNCTION_TYPE GetJunctionType(){return m_JunctionType;}
    const TCHAR* GetJunctionTypeName();

private:
    TCHAR    m_szJunctPath[MAX_PATH];
    TCHAR    m_szTgtPath[MAX_PATH];
    JUNCTION_TYPE m_JunctionType;

    static const TCHAR szTypeNameS[][50];

};

#endif //#ifndef _CJUNCTION_H_

